package o;

import java.io.IOException;

public final class aes {
    private static final long[] ˊ = new long[]{128, 64, 32, 16, 8, 4, 2, 1};
    private final byte[] ˋ = new byte[8];
    private int ˎ;
    private int ˏ;

    public void ˊ() {
        this.ˎ = 0;
        this.ˏ = 0;
    }

    public long ˊ(adv o_adv, boolean z, boolean z2, int i) throws IOException, InterruptedException {
        if (this.ˎ == 0) {
            if (!o_adv.ˊ(this.ˋ, 0, 1, z)) {
                return -1;
            }
            this.ˏ = ˋ(this.ˋ[0] & 255);
            if (this.ˏ == -1) {
                throw new IllegalStateException("No valid varint length mask found");
            }
            this.ˎ = 1;
        }
        if (this.ˏ > i) {
            this.ˎ = 0;
            return -2;
        }
        if (this.ˏ != 1) {
            o_adv.ˏ(this.ˋ, 1, this.ˏ - 1);
        }
        this.ˎ = 0;
        return ॱ(this.ˋ, this.ˏ, z2);
    }

    public int ˋ() {
        return this.ˏ;
    }

    public static int ˋ(int i) {
        for (int i2 = 0; i2 < ˊ.length; i2++) {
            if ((ˊ[i2] & ((long) i)) != 0) {
                return i2 + 1;
            }
        }
        return -1;
    }

    public static long ॱ(byte[] bArr, int i, boolean z) {
        long j = ((long) bArr[0]) & 255;
        if (z) {
            j &= ˊ[i - 1] ^ -1;
        }
        long j2 = j;
        for (int i2 = 1; i2 < i; i2++) {
            j2 = (j2 << 8) | (((long) bArr[i2]) & 255);
        }
        return j2;
    }
}
